package com.yanqu.road.dao.impl.config;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.config.robot.RobotTempConfig;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ：zfr
 * @date ：2021/5/13 20:37
 */
public class RobotConfigDaoImpl extends TempDao {
    public Map<Integer, RobotTempConfig> getRobotTempConfigMap() {
        ResultSet rs = null;
        CallableStatement call = null;
        String sql = "select * from t_s_robot_temp";
        Map<Integer, RobotTempConfig> configMap = new HashMap<>();
        try {
            getDb().setConnName(DbNameStrategy.getServerDb());
            call = getDb().getConnection().prepareCall(sql);
            rs = call.executeQuery();
            while (rs.next()) {
                RobotTempConfig config = new RobotTempConfig();
                config.setTitleId(rs.getInt("titleId"));
                config.setPrestigeParam(rs.getString("prestigeParam"));
                config.setPatronsParam(rs.getString("patronsParam"));
                config.setVehicleParam(rs.getString("vehicleParam"));
                config.setBeautyParam(rs.getString("beautyParam"));
                config.setPatronsAbilityParam(rs.getString("patronsAbilityParam"));
                config.setEstateWarIdParam(rs.getString("EstateWarIdParam"));
                config.setHouseLvParam(rs.getString("houseLvParam"));
                config.setBuildParam(rs.getString("buildParam"));
                config.setPassParam(rs.getString("passParam"));

                configMap.put(config.getTitleId(), config);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            getDb().closeConnection(call, rs);
        }
        return configMap;
    }
}
